package com.zwxu.junior;

import java.util.Scanner;

/*
 * 你输入的一行：abc cde efg   next-返回 abc nextLine-返回abc cde efg
 * while和if区别,if时一旦有个线程满足条件,则该判断一致为true
 */
public class MultiThreadDemo {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		//华为笔试标准格式  谨记输出字符串用nextLine
		int n = scanner.nextInt();
		MyThread m1 = new MyThread('A',n);
		m1.start();
		MyThread m2 = new MyThread('B');
		m2.start();
		MyThread m3 = new MyThread('C');
		m3.start();
		MyThread m4 = new MyThread('D');
		m4.start();
	}

}

class MyThread extends Thread{
	public static Object lock = new Object();
	
	public static char start = 'A';
	
	public char c;
	
	public static int n;
	
	public MyThread(char c) {
		super();
		this.c = c;
	}


	public MyThread(char c, int n) {
		super();
		this.c = c;
		this.n = n;
	}

	public void run(){
		for(int i=0;i<n;i++){
			synchronized(lock){
				System.out.print(start);
				start += 1;
		        if (start == 'E') {
		            start = 'A';
		        }
			}	
		}
	}
}
